/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jellyfishumbrella.GL;
import java.util.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.*;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import java.awt.geom.*;
import org.lwjgl.util.vector.*;
import java.util.concurrent.*;
import java.nio.*;
import org.lwjgl.BufferUtils;

/**
 *
 * @author 500441547
 */
public class Material {
    private static FloatBuffer tempBuffer = BufferUtils.createFloatBuffer(4);
    private static float[] amb;
    private static float[] diff;
    private static float[] spec;
    private static float gloss;

    public Material(){
        
    }

    public Material(float[] ambColor, float[] diffColor, float[] specColor, float glossy){
	amb = ambColor;
	diff = diffColor;
	spec = specColor;
	gloss = glossy;
    }

    public static void render(){
	loadTempBuffer(amb);
	glMaterial(GL_FRONT_AND_BACK,GL_AMBIENT, tempBuffer);
	loadTempBuffer(diff);
	glMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE, tempBuffer);
	loadTempBuffer(spec);
	glMaterial(GL_FRONT_AND_BACK,GL_SPECULAR, tempBuffer);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, gloss);
    }

    private static void loadTempBuffer(float[] data){
	tempBuffer.rewind();
	tempBuffer.put(data);
	tempBuffer.flip();
    }
}
